#coding=utf-8
from Utilities.AutoGetOperator.selectPackage import get_func

Operator_IVQ_ROFS=get_func(r'Operators/OperationOperators/OperatorIVQROF.py','Operator_IVQ_ROFS')


class Mm_q_rung(Operator_IVQ_ROFS):

    def  getResult(self):
        line=self.data_list
        weight=self.weight_list
        a=self.a
        n = len(line)-1
        result = self.pow(line[0], a, q)
        for i in range(1,n):
            temp1 = self.kmulti(self.pow(line[i], a, q),weight[i],q)
            result = self.add(result, temp1, q)
            result=self.pow(result,1/a,q)
        return result

def Mm_q_matrix(matrix,weight,q):
    '''

    :param matrix: 传入一个矩阵
    :param weight: 权重
    :param q:
    :return: 用上述方法返回一列区间值广义正交模糊数
    '''
    n=len(matrix)
    alternative=[]
    for i in range(n):
        temp=Mm_q_rung(matrix[i],weight,q)
        alternative.append(temp)
    return alternative




if __name__=="__main__":
    n=20
    q=3
    a=3
    data_list = [([0.31, 0.24], [0.73, 0.72]), ([0.97, 0.12], [0.12, 0.05]),
                 ([0.8, 0.52], [0.73, 0.15]), ([0.91, 0.49], [0.42, 0.47]), ([0.95, 0.06], [0.19, 0.1])]
    weight_list = [0.1, 0.2, 0.3, 0.1, 0.3]

    alternative=Mm_q_rung(data_list,weight_list,a,q)
    result=alternative.getResult()
    print(result)